. _
[Random]

Neovim Shortcuts

Movement commands

e move to end of word
w move to start of word
b back to previous word

Visual mode

v to start visual mode
<C-v> to start visual block mode
<Esc> to exit visual mode

Delete commands

dw to delete word
diw to delete inside word
daw to delete around word
d3w to delete 3 words
d$ to delete till end of line
d0 to delete till start of line
d^ to delete till first non-blank character of the line

Change commands

cw to change word
ciw to change inside word
caw to change around word
c3w to change 3 words
c$ to change till end of line
c0 to change till start of line
c^ to change till first non-blank character of the line

Yank commands

yw to yank word
yy to yank line

Paste commands

p to paste after
P to paste before

Run any command inside vim

:!ls -alh to run command
:!touch file1 to run command and create file

Reading external command output

:r !ls to run command and put output in buffer

Substitution commands

:s/old/new/g to replace all in current line
:s/old/new/gc to replace all in current line with confirmation
:%s/old/new/g to replace all in the file

advanced example:
:s/Your mom/you Dad/gc to replace all in the current line with confirmation
:%s/Your mom/you Dad/gc to replace all in the file with confirmation

Global (:g) commands

:g/old/d to delete all lines matching pattern

Quit commands

:q to quit
:q! to quit without saving

Write commands

:w to write
:w !sudo tee to write as root

switch tabs

gt and gT are Vim's shortcuts to jump to next & previous tabs

you can also go to specific tab by index number and then gt


If you already have a Visual Line selection (V)
You can switch to block mode on the fly:

Select lines with V (visual line mode) or vip etc.
Press Ctrl-V to switch to block mode.
Then press I + your text + Esc.

Or use the command-line way after selecting lines:

After visual selection: :'<,'>normal! I#

Common examples

Add # at the start of each line (e.g. for commenting):
Go to column 0 on the first line.
Ctrl-V → select down with j → I# → Esc

Add two spaces at the beginning:
Ctrl-V → select → I (type two spaces) → Esc

Add // (comment in many languages):
Ctrl-V → select → I// → Esc

0%